<?php

/**
 * Created by PhpStorm.
 * User: Sergey
 * Date: 07.04.2014
 * Time: 11:19
 */
class MarkConverter
{
    public static function to_5_point($score, $maxScore)
    {
        return sprintf("%.2f", ($score / $maxScore) * 5);
    }

    public static function to_100_point($score, $maxScore)
    {
        return sprintf("%.2f", ($score / $maxScore) * 100);
    }

    public static function to_ABCDEF_point($score, $maxScore)
    {
        $resultScore = self::to_100_point($score, $maxScore);
        $mark = "";
        if (90 <= $resultScore && $resultScore <= 100) {
            $mark = "A";
        } elseif (82 <= $resultScore && $resultScore <= 89) {
            $mark = "B";
        } elseif (74 <= $resultScore && $resultScore <= 81) {
            $mark = "C";
        } elseif (64 <= $resultScore && $resultScore <= 73) {
            $mark = "D";
        } elseif (60 <= $resultScore && $resultScore <= 63) {
            $mark = "E";
        } elseif (35 <= $resultScore && $resultScore <= 59) {
            $mark = "FX";
        } elseif (1 <= $resultScore && $resultScore <= 34) {
            $mark = "F";
        }
        return $mark;
    }
}